package com.zqh.app.manager.impl;

import com.zqh.app.dao.AdMapper;
import com.zqh.app.dao.ArchivesMapper;
import com.zqh.app.entity.Archives;
import com.zqh.app.entity.SungoAd;
import com.zqh.app.manager.AdManager;
import com.zqh.app.manager.AppArchivesManager;
import com.zqh.common.entity.Page;
import com.zqh.common.entity.Query;
import com.zqh.common.entity.R;
import com.zqh.common.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("adManager")
public class AdManagerImpl implements AdManager {

    @Autowired
    AdMapper adMapper;
    @Override
    public R addAd (Query form) {
        int count = adMapper.save(form);
        return CommonUtils.msg(count);
    }

    @Override
    public R updateAd(Query form) {
        int count = adMapper.update(form);
        return CommonUtils.msg(count);
    }

    @Override
    public R delAd(int archivesId) {
        int count = adMapper.remove(archivesId);
        return CommonUtils.msg(count);
    }

    @Override
    public List<SungoAd> getAds(Page<SungoAd> page, Query query) {
        return adMapper.listForPage(page, query);
    }
}
